package com.wl.system.config;

import com.wl.common.security.register.SecurityMetadataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author: wanglin
 * @date: 2024-03-08 周五
 * @Version: 1.0
 * @Description:
 */
@Slf4j
@Component
public class DynamicMetadataSourceConfig {

    @Autowired
    private SecurityMetadataSource metadataSource;

    @PostConstruct
    public Map<String, String> loadDataSource() {
        log.info("DynamicMetadataSourceConfig: 初始化加载系统资源。。。。。。。。");
        log.info("sys:loading system resources.....");
        ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>(16);
        map.put("sys/user/page*", "COMMON");
        map.put("sys/user/list*", "COMMON");
        map.put("sys/role/page*", "COMMON");
        map.put("sys/role/list*", "COMMON");
        metadataSource.setResourceMap(map);
        return map;
    }
}
